package com.cqq.print.base.service.impl;


import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cqq.print.base.dao.PBookCategoryDao;
import com.cqq.print.base.dao.domain.PBookCategory;
import com.cqq.print.base.service.PBookCategoryService;
import com.cqq.print.base.service.bean.PBookCategoryBean;


/**
 * @author generated
 * @date 2015-07-01
 */


@Service(value="pBookCategoryService")
public class PBookCategoryServiceImpl implements PBookCategoryService{

            @Autowired
            private PBookCategoryDao pBookCategoryDao;

			
			public List<PBookCategoryBean> queryBookCateGory() {
				List<PBookCategory> listCategory = pBookCategoryDao.queryBookCateGory();
				List<PBookCategoryBean> listBean = null;
				if(listCategory!=null&&listCategory.size()>0){
					listBean = new ArrayList<PBookCategoryBean>();
					for (PBookCategory category : listCategory) {
						PBookCategoryBean bean = new PBookCategoryBean();
						BeanUtils.copyProperties(category, bean);
						listBean.add(bean);
					}
				}
				return listBean;
			}

			
			public int insertBookCateGory(PBookCategoryBean categoryBean) {
				if(categoryBean==null)
				return 0;
				PBookCategory record = new PBookCategory();
				BeanUtils.copyProperties(categoryBean, record);
				return pBookCategoryDao.insertSelective(record);
			}

			
			public List<PBookCategoryBean> findByName(String name) {
				if(name==null)
					return null;
				List<PBookCategory> listCategory= pBookCategoryDao.findByName(name);
				List<PBookCategoryBean> listBean = null;
				if(listCategory!=null&&listCategory.size()>0){
					listBean = new ArrayList<PBookCategoryBean>();
					for (PBookCategory category : listCategory) {
						PBookCategoryBean bean = new PBookCategoryBean();
						BeanUtils.copyProperties(category, bean);
						listBean.add(bean);
					}
				}
				return listBean;
			}

}